package com.piik.mall.cart.vo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;

public class test {

    private static final Logger logger = LoggerFactory.getLogger(test.class);

    public static String readTxt(File file) throws IOException {
        String s = "";
        InputStreamReader in = new InputStreamReader(new FileInputStream(file), "UTF-8");
        BufferedReader br = new BufferedReader(in);
        StringBuffer cOntent = new StringBuffer();
        while ((s = br.readLine()) != null) {
            System.out.println(s);
            cOntent = cOntent.append(s);
            cOntent.delete(0,100);
        }
        br.close();
        boolean flag = false;
        //根据路径创建文件对象
        File file1 = new File("d:\\du.txt");
        //路径是个文件且不为空时删除文件
        if(file1.isFile() && file1.exists()){
            flag = file1.delete();
        }

        System.out.println(flag);
        return cOntent.toString();
    }

    public static void main(String[] args) {
        try {
            String s1 = test.readTxt(new File("d:\\du.txt"));
            System.out.println(s1);


           // String s2 = test.readTxt(ResourceUtils.getFile("classpath:du.txt"));
           // logger.info(s2);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
